using System;
using System.Collections.Generic;
using System.Text;
using Ghasam.Business.Domain.Entity;
using NHibernate;
using NHibernate.Expression;

namespace Ghasam.Business.DAO.Impl
{
    public class EmployeeDao : DaoBase<Employee>, IEmployeeDao
    {
        public IList<Employee> searchEmployee(string firstName, string lastName, int? empId, DateTime? joinedDate,bool? isFormal)
        {
            ICriteria cri = base.Session.CreateCriteria(typeof(Employee));
            if (firstName.Length > 0)
                cri.Add(Expression.Like("FirstName", firstName,MatchMode.Anywhere));
            if (lastName.Length > 0)
                cri.Add(Expression.Like("LastName", lastName, MatchMode.Anywhere));
            if (empId.HasValue)
                cri.Add(Expression.Eq("Id", empId.Value));
            if (joinedDate.HasValue)
                cri.Add(Expression.Eq("JoinedDate", joinedDate.Value));
            cri.Add(Expression.Eq("IsFormal", isFormal));
            return cri.List<Employee>();
        }
    }
}
